package Servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class Home
 */
@WebServlet("/Home")
public class LoginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public LoginServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub

		
		/*String urlParameters = "param1=a&param2=b&param3=c";
		String request1 = "http://devopenerp.brice-newton.fr/web/webclient/home";
		URL url = new URL(request1); 
		HttpURLConnection connection = (HttpURLConnection) url.openConnection();           
		connection.setDoOutput(true);
		connection.setDoInput(true);
		connection.setInstanceFollowRedirects(false); 
		connection.setRequestMethod("POST"); 
		connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); 
		connection.setRequestProperty("charset", "utf-8");
		connection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));
		connection.setUseCaches (false);

		DataOutputStream wr = new DataOutputStream(connection.getOutputStream ());
		wr.writeBytes(urlParameters);
		wr.flush();
		wr.close();
		connection.disconnect();*/
		
	
		
		
		/*HttpClient client = new HttpClient();

		// Create POST method
		String url = "http://www.discursive.com/cgi-bin/jccook/param_list.cgi";
		PostMethod method = new PostMethod(url);
		// Set parameters on POST    
		method.setParameter( "test1", "Hello World" );
		method.addParameter( "test2", "This is a Form Submission" );
		method.addParameter( "Blah", "Whoop");
		// Execute and print response
		client.executeMethod(method);*/
		
		//response.sendRedirect("http://devopenerp.brice-newton.fr/web/webclient/home?test=88");
		/*RequestDispatcher dispat = request.getRequestDispatcher("http://devopenerp.brice-newton.fr/web/webclient/home"); 
		dispat.forward(request,response); */
		
		
		  // get the application object
	    ServletContext app = getServletContext();

	    // select login.jsp as the template
	    RequestDispatcher disp;
	    disp = app.getRequestDispatcher("/jsp/Login.jsp");

	    // forward the request to the template
	    disp.forward(request, response);

	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub	
		doGet(request,  response) ;
	}

}
